/*
 * tc.h
 *
 * Created: 04/02/2014 21:11:58
 *  Author: usuario
 */ 

#ifndef TC_H_
#define TC_H_

#include <dronus.h>
#include <rtos.h>

#define TC						TC0
#define TC_CHANNEL_CAPTURE		0

#define ID_TC_CAPTURE			ID_TC0
#define PIN_TC_CAPTURE			PIN_TC0_TIOA0
#define PIN_TC_CAPTURE_MUX		PIN_TC0_TIOA0_MUX

#define TC_Handler				TC0_Handler
#define TC_IRQn					TC0_IRQn

#define PULSES_NUM_PULSES		1

#define PULSES_MAX_BLOCK_TIME	( 50 * portTICK_RATE_MS )

typedef struct
{
	uint64_t up;  
	uint64_t down; // microseconds
} pulse_t;

typedef pulse_t pulses_t[PULSES_NUM_PULSES];

void PULSES_setup ( void );
void PULSES_get_pulses(pulses_t *ptr_pulses, portTickType block_time_ticks, xSemaphoreHandle notification_semaphore);

#endif /* TC_H_ */